﻿using System.Windows;
using System.Windows.Data;

namespace ibba.src.sl.recursos.Converters
{
    public class EqualsToVisibilityConverter: IValueConverter
    {
        #region IValueConverter Members

        public object Convert(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value != null && parameter != null)
                if (parameter.ToString().Contains("!"))
                {
                    return (!value.ToString().Equals(parameter.ToString().Replace("!", "")))
                            ? Visibility.Collapsed : Visibility.Visible;
                }
                else
                {
                    return (value.ToString().Equals(parameter.ToString()))
                            ? Visibility.Visible : Visibility.Collapsed;
                }
            else
                return Visibility.Collapsed;
        }

        public object ConvertBack(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            return value;
        }

        #endregion
    }
}
